package com.bestescortbedsystem.controller.report;

import com.bestescortbedsystem.entity.SesUserReport;
import com.bestescortbedsystem.service.ReportService;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

/*
* 维修记录
*
* */
@RestController
@RequestMapping("report")
@Slf4j
@Api(tags = "维修控制层")
public class ReportController {
    @Resource
    private ReportService reportService;
    /**
    *查询条件
    * @param reportId 维修id
    * @param userId 维修人id
    * @param reportStatus 维修状态
    * @param pageNum
    * @param pageSize
    */
    @RequestMapping ("list")
    public Map<String,Object> reportList(@RequestParam(defaultValue = "10") Integer pageSize, Integer pageNum, Long reportId, Long userId, String reportStatus){
        Map<String,Object> map=new HashMap<>();
        try{
            map=reportService.getAllReport(pageSize,pageNum,reportId,userId,reportStatus);
            map.put("result",true);
        }catch (Exception e){
            map.put("result",false);
        }finally {
            return map;
        }
    }
    /**
     * 删除维修记录
     * @param reportId 维修id
     **/
    @RequestMapping("delete")
    public Map<String,Object> deleteReport(Long reportId){
        Map<String,Object> map=new HashMap<>();
        try{
            reportService.deleteReport(reportId);
            map.put("result",true);
        }catch (Exception e){
            map.put("result",false);
        }finally {
            return map;
        }
    }
}
